/*
 * @Author: spring
 * @version:
 * @Date: 2022-09-07 14:52:20
 * @LastEditors: spring
 * @LastEditTime: 2022-09-18 09:36:30
 * @Descripttion:
 */

#ifndef _CAR_THREAD_H_
#define _CAR_THREAD_H_
#include <poll.h>
#include <vector>
#include <pthread.h>
#include <sys/epoll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "./Com_format.h"
#include "Com_tcp.h"

extern pthread_mutex_t mutex_wait_terminal;
extern pthread_mutex_t mutex_epoll_ctl;

struct thread_args
{
    wait_arg app;
    wait_arg car;
    std::vector<std::pair<wait_arg, wait_arg>> &arr_com;
    int epoll_fd;
};

void *Com_thread(void *);

/**
 * @msg: 获取一个完整的通信帧，函数内部使用malloc申请堆空间，使用完后需要释放 free(cmd) ;
 * @param {int} socketfd 待接收数据的套接字文件描述符
 * @param {char} *：返回的数据
 * @return {*} 成功返回 命令总大小，失败 -1 ,0表示断开连接
 */
int readCom(int socketfd, char **cmd);

#endif
//_CAR_THREAD_H_
